package com.scm.filter;

/**
 * @author CHL
 * @ClassName: EncodingFilter
 * @Description: TODO
 * @date 2022/3/8 15:13
 * @Version 1.0
 */

import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Component
@Order(2)
public class EncodingFilter
        implements Filter
{
    @Override
    public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain arg2)
            throws IOException, ServletException
    {
        arg0.setCharacterEncoding("UTF-8");

        arg2.doFilter(arg0, arg1);
    }
}
